package edu.gdkm.dao;


import edu.gdkm.pojo.Course;
import edu.gdkm.pojo.Student;
import org.apache.ibatis.annotations.*;

public interface IStudentDao {
    @Select("select * from t_student where sid=#{id}")
    public Student queryStudentById(Integer id);

    @Select("select * from t_student where cid=#{cid}")
    public Student queryStudentByCid(Integer cid);

    @Select("select * from t_student where sid=#{sid}")
    @Results({
            @Result(
                    property = "course",
                    column = "cid",
                    one=@One(select = "edu.gdkm.dao.ICourseDao.queryCourseById")
            )
    })
    public Student queryCourseAndTeacherBySid(Integer sid); //根据Sid显示已选课程和对应的老师名称

    @Update("update t_student set cid = #{course.cid} where sid = #{sid}")
    public Integer updateStudent(Student student);  //选课或更改已选课程

    @Select("select * from t_student where cid=#{cid}")
    public Student queryStudentsByCid(Integer cid);
}
